package org.project.hint_game;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

/** Room Numbers
0: Kitchen
1: Dining Hall
2: Library
3: Ballroom
4: Bedroom
5: Courtyard
6: Dungeon
7: Armory
**/

public class RoomSelectActivity extends Activity{
	private ImageButton kitchenButton_;
	private ImageButton bedroomButton_;
	private ImageButton dungeonButton_;
	private ImageButton courtButton_;
	private ImageButton ballroomButton_;
	private ImageButton diningButton_;
	private ImageButton armoryButton_;
	private ImageButton libraryButton_;
	
	private int currentRoom_;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_room_select);
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        
        // Initialize private variables
        kitchenButton_ = (ImageButton) findViewById(R.id.kitchenImgButton);
        bedroomButton_ = (ImageButton) findViewById(R.id.bedroomImgButton);
        dungeonButton_ = (ImageButton) findViewById(R.id.dungeonImgButton);
        courtButton_ = (ImageButton) findViewById(R.id.courtImgButton);
        ballroomButton_ = (ImageButton) findViewById(R.id.ballroomImgButton);
        diningButton_ = (ImageButton) findViewById(R.id.diningImgButton);
        armoryButton_ = (ImageButton) findViewById(R.id.armoryImgButton);
        libraryButton_ = (ImageButton) findViewById(R.id.libraryImgButton);
        
        dungeonButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Only go to room if allowed
            	if (currentRoom_ == -1 || currentRoom_ == 5 || currentRoom_ == 2 || currentRoom_ == 7){
            		Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
            		intent.putExtra("roomChoice", 6);	// Send room information
            		startActivity(intent);
            	}
            }
        });
        armoryButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Only go to room if allowed
            	if (currentRoom_ == -1 || currentRoom_ == 0 || currentRoom_ == 6){
            		Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
            		intent.putExtra("roomChoice", 7);	// Send room information
            		startActivity(intent);
            	}
            }
        });
        kitchenButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Only go to room if allowed
            	if (currentRoom_ == -1 || currentRoom_ == 1 || currentRoom_ == 7 || currentRoom_ == 4){
            		Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
            		intent.putExtra("roomChoice", 0);	// Send room information
            		startActivity(intent);
            	}
            }
        });
        bedroomButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	// Only go to room if allowed
                if (currentRoom_ == -1 || currentRoom_ == 5 || currentRoom_ == 3 || currentRoom_ == 0){
                	Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
                	intent.putExtra("roomChoice", 4);	// Send room information
                	startActivity(intent);
                }
            }
        });
        courtButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Only go to room if allowed
            	if (currentRoom_ == -1 || currentRoom_ == 4 || currentRoom_ == 6){
            		Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
            		intent.putExtra("roomChoice", 5); // Send room information
            		startActivity(intent);
            	}
            }
        });
        ballroomButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (currentRoom_ == -1 || currentRoom_ == 2 || currentRoom_ == 4){
                	Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
                	intent.putExtra("roomChoice", 3);
                	startActivity(intent);
                }
            }
        });
        diningButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (currentRoom_ == -1 || currentRoom_ == 2 || currentRoom_ == 0){
                	Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
                	intent.putExtra("roomChoice", 1);
                	startActivity(intent);
                }
            }
        });
        libraryButton_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	if (currentRoom_ == -1 || currentRoom_ == 3 || currentRoom_ == 1 || currentRoom_ == 6){
                	Intent intent = new Intent(RoomSelectActivity.this, MainRoomActivity.class);
                	intent.putExtra("roomChoice", 2);
                	startActivity(intent);
                }
            }
        });
	}
	
	/*private void goToMainRoom(int roomNumber){
		
	}*/
	
	protected void onResume(){
		super.onResume();
		currentRoom_ = this.getIntent().getIntExtra("currentRoom", 0);
	}
	@Override
	protected void onStop() {
	    super.onStop();
	}

	@Override
	protected void onDestroy() {
	    super.onDestroy();
	}
}